package ${basePackage}.${module}.controller;

import ${basePackage}.${module}.domain.*;
import ${basePackage}.${module}.service.*;
import ${basePackage}.manage.service.LogService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import ${basePackage}.manage.controller.BaseController;
import org.springframework.web.bind.annotation.*;
import ${basePackage}.common.pojo.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("/api/${table.camelName}")
public class ${table.className}Controller extends BaseController {


@Resource
private ${table.className}Service ${table.camelName}Service;

@Resource
private LogService logService;


@ApiOperation(value = "列出所有的${table.comment}", notes = "requires noting")
@GetMapping(value = "/list")
@RequiresPermissions("${table.camelName}:list")
public Object list(String keyword,Pager pager) {
    return ${table.camelName}Service.list(keyword,pager);
}


@GetMapping(value = "/{id}")
public Object get(@PathVariable("id") Integer id) {
    return ${table.camelName}Service.get${table.className}(id);
}

@RequiresPermissions("${table.camelName}:add")
@PostMapping
public Object insert(@RequestBody ${table.className}DO ${table.camelName}DO) {
    ${table.camelName}Service.save(${table.camelName}DO);
    logService.info( "添加或修改了新的${table.comment}%s", ${table.camelName}DO.toString());
    return Result.success(${table.camelName}DO);
}

@RequiresPermissions("${table.camelName}:delete")
@PostMapping(value = "/delete")
public Object delete(@RequestBody Set<Integer> ids) {
    ${table.camelName}Service.delete(ids);
    logService.info( "删除了${table.comment}%s", ids.toString());
    return Result.success(null);
}


}
